#include "stdafx.h"
#include "Label.h"

namespace Framework {

Label::Label(Game* game) : DrawableGameComponent(game) {
    this->font = NULL;
    this->format = DT_TOP | DT_LEFT;
}

Label::~Label(void) {
}

DWORD Label::GetFormat() const {
    return this->format;
}

void Label::SetFormat(DWORD val) {
    this->format = val;
}

D3DXMATRIX Label::GetWorldMatrix() {
    return D3DXMATRIX();
}

void Label::SetText(string text) {
    this->text = text;
}

void Label::Draw(FLOAT timeDelta) {
    this->font->DrawTextA(NULL, this->text.c_str(), -1, &this->bounds, this->format, 0xffffffff);
}

void Label::LoadContent() {
    D3DXFONT_DESC lf;
    ZeroMemory(&lf, sizeof(D3DXFONT_DESC));
    lf.Height = 25;
    lf.Width = 12;
    lf.Weight = 500;
    lf.MipLevels = 1;
    lf.Italic = false;
    lf.CharSet = DEFAULT_CHARSET;
    lf.OutputPrecision = OUT_TT_PRECIS;
    lf.Quality = CLEARTYPE_NATURAL_QUALITY;
    lf.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
    strcpy_s(lf.FaceName, "Courier New");

    D3DXCreateFontIndirect(this->GetGame()->GetGraphicsDevice(), &lf, &this->font);
}

}
